#ifndef ECOMMAND_H 
#define ECOMMAND_H 1

#include <DefineLibCommon.h>
#include <DefineCommon.h>
#include <EItem.h>
#include <EItemMeta.h>

/** This class represent a command in UI system or EItem system.
 * For example, when the WidgetTree add a new tree item, then a ECommand
 * is pushed into ECommandManager.
 * ECommandManager will loop ECommand list and dispatch to other class by delegate.
 * ECommand is inherited from EItem, so user can add any property, type expansion is avoided
 * ECommand may be arranged as a tree struct in future using.
 * */
class ECommand;
typedef SmartPtr(ECommand) ECommandPtr;
class COMMON_DLL ECommand : public EItem
{
public:

    enum STATE
    {
        NORMAL,
        UNDO,
        REDO
    };

    ECommand();
    virtual ~ECommand();

    void setSender(long ptr);
    long getSender();

    void setSenderName(const EString& str);
    EString getSenderName();

    void setState(STATE s);
    STATE getState();

    void setIfEnableUndo(bool ifEnable);
    bool getIfEnableUndo();

protected:
    long m_senderTag;
    EString m_senderName;

    //indicate if this command should be pushed in undo stack while ECommandManager handle this command
    bool m_ifEnableUndo=true;
    //indicate if this command is used for Redo(false) or Undo(true)
    STATE m_state;

};

#endif // !ECOMMAND_H

